#!/bin/tcsh
#
#  This script runs NWChem on mnemosyne
#
module load mpich
module load nwchem/6.5
#
setenv NWCHEM_PROCS 4
setenv NWCHEM_MEMORY "1200 mb"
setenv NWCHEM_SCRATCH /home/mark/nwchem/scratch
#
set procid=`echo $$`
setenv JOBNAME `ps -p $procid | grep $procid | awk '{print $4}'`
setenv NWCHEM_ROOT `echo $JOBNAME | awk -F_ '{print $1}'`
setenv NWCHEM_SUFFIX `echo $JOBNAME | awk -F_ '{print $2}'`
mkdir $NWCHEM_SCRATCH/$procid
#
# Build the input file
#
cat << finis > $JOBNAME.nw
title "water optimization"

start  $NWCHEM_ROOT
permanent_dir $cwd
scratch_dir $NWCHEM_SCRATCH/$procid
memory $NWCHEM_MEMORY
print low
ecce_print $JOBNAME.ecce

charge 0

geometry  autosym units angstrom
  zmatrix
    O1      
    H1     O1       1.0
    H2     O1       1.0    H1  108.
  end
end

basis 
  * library "6-31++G**"
end

dft
  xc b3lyp
  iterations 1000
  direct
  noio
end


task dft optimize

dplot
  vectors $NWCHEM_ROOT.movecs
  limitxyz units angstrom
  -3.0  3.0  100
  -3.0  3.0  100
  -3.0  3.0  100
  spin total
  where g+n
  gaussian
  output $NWCHEM_ROOT.cube
end

task dplot
finis
#
#   Run the job
#
mpirun -np $NWCHEM_PROCS nwchem $JOBNAME.nw >& $JOBNAME.nwo
#
#   Clean up scratch directory
rm -rf $NWCHEM_SCRATCH/$procid

